package com.jiawa.train.business.service.Impl;

import org.redisson.api.RBloomFilter;
import org.springframework.stereotype.Service;

@Service
public class UserService {
    private final RBloomFilter<String> bloomFilter;

    public UserService(RBloomFilter<String> bloomFilter) {
        this.bloomFilter = bloomFilter;
    }

    // 用户注册时添加到布隆过滤器
    public void registerUser(String userId) {
        bloomFilter.add(userId);
    }

    // 登录时检查布隆过滤器
    public boolean isUserPossiblyRegistered(String userId) {
        return bloomFilter.contains(userId);
    }
}
